package com.example.administrator.myapplication.uilts;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.myapplication.R;

/**
 * Created by 董豪华 on 2017/1/6.
 */
public class XingzuoAdapter extends BaseAdapter {
    private String xingzuo[] = {"白羊座","金牛座","双子座","巨蟹座","狮子座","处女座","天秤座","天蝎座","射手座",
            "摩羯座","水瓶座","双鱼座"};
    private String shuzhu[];
    int tutu [] = {R.drawable.baiyang,R.drawable.jingniu,R.drawable.shizi,R.drawable.juxie,R.drawable.shizi,R.drawable.xhunv,
            R.drawable.tainchen,R.drawable.tainxie,R.drawable.sheshou,R.drawable.moxie,R.drawable.shuiping,R.drawable.shuangyu};
    Context context;
    public XingzuoAdapter(Context context){
        this.context = context;
        setShuzhu(xingzuo);
    }
    @Override
    public int getCount() {
        return xingzuo.length;
    }

    @Override
    public Object getItem(int position) {
        return xingzuo[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = View.inflate(context, R.layout.xingzuo_gridview_item,null);
        TextView viewById = (TextView) view.findViewById(R.id.xingzuo);
        ImageView xinguotu = (ImageView) view.findViewById(R.id.xinguotu);
        xinguotu.setBackgroundResource(tutu[position]);
        viewById.setText(xingzuo[position]);
        return view;
    }

    public String[] getShuzhu() {
        return shuzhu;
    }

    public void setShuzhu(String[] shuzhu) {
        this.shuzhu = shuzhu;
    }
}
